10 REM MOMENT METHOD SOLUTION TO WIRE DIPOLE
20 REM "ANTENNA DESIGN USING PERSONAL COMPUTERS"
30 DIM ZLR(11),ZLI(11),CR(11),CI(11),V(11)
40 DIM ZR(66),ZI(66),A(5)
50 DEF FNCABS(X,Y)=SQR(X*X+Y*Y)
60 DEF FNDIVR(X1,Y1,X2,Y2)=(X1*X2+Y1*Y2)/(X2*X2+Y2*Y2)
70 DEF FNDIVI(X1,Y1,X2,Y2)=(Y1*X2-X1*Y2)/(X2*X2+Y2*Y2)
80 DEF FNINDX(I,J,N)=(I-1)*N-(I*I-I)/2+J
90 DEF FNLOG10(X)=.4343*LOG(X)
100 PI=3.141593
110 KEY OFF
120 CLS
130 COLOR 1,0
140 PRINT "THIS PROGRAM DOES A MOMENT METHOD SOLUTION FOR A"
150 PRINT "WIRE DIPOLE IN FREE-SPACE."
160 COLOR 4,0
170 PRINT
180 INPUT "WHAT IS THE FREQUENCY(MHz)";FMC
190 INPUT "WHAT IS THE DIPOLE LENGTH(meters)";DL
200 INPUT "WHAT IS THE DIPOLE RADIUS(meters)";AM
210 INPUT "HOW MANY PWS EXPANSION MODES";N
220 IF N>11 THEN GOTO 210
230 D=DL/(N+1)
240 COLOR 14,0
250 PRINT "MODE #     CO-ORD"
260 FOR I=1 TO N
270 Z=-DL/2+I*D
280 PRINT USING "   ##     ###.###";I,Z
290 NEXT I
300 COLOR 4,0
310 INPUT "AT WHAT MODE IS THE FEED POINT";NF
320 IF NF>N THEN GOTO 310
330 IF NF<1 THEN GOTO 310
340 FOR I=1 TO N
350 ZLR(I)=0
360 ZLI(I)=0
370 NEXT I
380 INPUT "ARE THERE LUMPED LOADS(Y,N)";LL$
390 IF LL$="N" THEN GOTO 440
400 FOR I=1 TO N
410 PRINT USING "TYPE THE COMPLEX LOAD IMPEDANCE AT MODE ##";I;
420 INPUT ZLR(I),ZLI(I)
430 NEXT I
440 REM COMPUTE Z MATRIX(TOP ROW ONLY)
450 COLOR 14,0
460 PRINT
470 XK0=2*PI*FMC/300
480 IF D<.0628/XK0 THEN PRINT "CAUTION - SEGMENT LENGTH < 0.01 WVL."
490 SKD=SIN(XK0*D)
500 CKD=COS(XK0*D)
510 FOR I=1 TO N
520 FOR J=I TO N
530 K=FNINDX(I,J,N)
540 IF I>1 THEN GOTO 610
550 X0=(J-1)*D
560 GOSUB 2240
570 ZR(K)=ZMNR
580 ZI(K)=ZMNI
590 PRINT I,J,ZMNR,ZMNI
600 GOTO 640
610 K1=FNINDX(I-1,J-1,N)
620 ZR(K)=ZR(K1)
630 ZI(K)=ZI(K1)
640 NEXT J
650 NEXT I
660 REM ADD LUMPED LOADS
670 FOR I=1 TO N
680 K=FNINDX(I,I,N)
690 ZR(K)=ZR(K)+ZLR(I)
700 ZI(K)=ZI(K)+ZLI(I)
710 NEXT I
720 REM COMPUTE VOLTAGE VECTOR
730 FOR I=1 TO N
740 V(I)=0
750 NEXT I
760 V(NF)=1
770 FOR I=1 TO N
780 K=FNINDX(I,J,N)
790 CR(I)=V(I)
800 CI(I)=0
810 NEXT I
820 REM SOLVE ZI=V
830 GOSUB 1140
840 ZINR=FNDIVR(1,0,CR(NF),CI(NF))
850 ZINI=FNDIVI(1,0,CR(NF),CI(NF))
860 REM PRINT CURRENT; COMPUTE POWERS
870 PRINT "MODE #   CURRENT(RE,IM)"
880 PD=0
890 FOR I=1 TO N
900 PRINT USING "   ##  ##.####  ##.####";I,CR(I),CI(I)
910 PD=PD+FNCABS(CR(I),CI(I))^2*ZLR(I)
920 NEXT I
930 PT=CR(NF)
940 EFF=(1-PD/PT)*100
950 PRINT
960 PRINT USING "INPUT IMPEDANCE=####.## #####.## ohms";ZINR,ZINI
970 PRINT USING "RADIATION EFFICIENCY=###.#%";EFF
980 REM COMPUTE BROADSIDE GAIN
990 GR=0
1000 GI=0
1010 FM=60*(1-CKD)/SKD
1020 FOR I=1 TO N
1030 GR=GR+CR(I)
1040 GI=GI+CI(I)
1050 NEXT I
1060 GB=FM*FM*(GR*GR+GI*GI)/(30*PT)
1070 GDB=10*FNLOG10(GB)
1080 PRINT USING "BROADSIDE GAIN= ##.## dB";GDB
1090 PRINT
1100 COLOR 4,0
1110 INPUT "CONTINUE(Y,N)";IS$
1120 IF IS$="N" THEN GOTO 2520
1130 GOTO 120
1140 REM CHOLESKY LINEAR EQUATION SOLUTION
1150 PHS=0
1160 IF ZR(1)<>0 THEN PHS=ATN(ZI(1)/ZR(1))/2
1170 MAG=SQR(FNCABS(ZR(1),ZI(1)))
1180 ZR(1)=MAG*COS(PHS)
1190 ZI(1)=MAG*SIN(PHS)
1200 FOR K=2 TO N
1210 ZINR=FNDIVR(ZR(K),ZI(K),ZR(1),ZI(1))
1220 ZINI=FNDIVI(ZR(K),ZI(K),ZR(1),ZI(1))
1230 ZR(K)=ZINR
1240 ZI(K)=ZINI
1250 NEXT K
1260 FOR I=2 TO N
1270 IMO=I-1
1280 IPO=I+1
1290 ID=(I-1)*N-(I*I-I)/2
1300 II=ID+I
1310 FOR L=1 TO IMO
1320 LI=FNINDX(L,I,N)
1330 ZINR=ZR(II)-ZR(LI)*ZR(LI)+ZI(LI)*ZI(LI)
1340 ZINI=ZI(II)-2*ZR(LI)*ZI(LI)
1350 ZR(II)=ZINR
1360 ZI(II)=ZINI
1370 NEXT L
1380 PHS=0
1390 IF ZR(II)<>0 THEN PHS=ATN(ZI(II)/ZR(II))/2
1400 MAG=SQR(FNCABS(ZR(II),ZI(II)))
1410 ZR(II)=MAG*COS(PHS)
1420 ZI(II)=MAG*SIN(PHS)
1430 IF IPO>N THEN GOTO 1600
1440 FOR J=IPO TO N
1450 IJ=ID+J
1460 FOR M=1 TO IMO
1470 MD=(M-1)*N-(M*M-M)/2
1480 MI=MD+I
1490 MJ=MD+J
1500 ZINR=ZR(IJ)-ZR(MJ)*ZR(MI)+ZI(MJ)*ZI(MI)
1510 ZINI=ZI(IJ)-ZR(MJ)*ZI(MI)-ZI(MJ)*ZR(MI)
1520 ZR(IJ)=ZINR
1530 ZI(IJ)=ZINI
1540 NEXT M
1550 ZINR=FNDIVR(ZR(IJ),ZI(IJ),ZR(II),ZI(II))
1560 ZINI=FNDIVI(ZR(IJ),ZI(IJ),ZR(II),ZI(II))
1570 ZR(IJ)=ZINR
1580 ZI(IJ)=ZINI
1590 NEXT J
1600 NEXT I
1610 ZINR=FNDIVR(CR(1),CI(1),ZR(1),ZI(1))
1620 ZINI=FNDIVI(CR(1),CI(1),ZR(1),ZI(1))
1630 CR(1)=ZINR
1640 CI(1)=ZINI
1650 FOR I=2 TO N
1660 IMO=I-1
1670 FOR L=1 TO IMO
1680 LI=FNINDX(L,I,N)
1690 ZINR=CR(I)-ZR(LI)*CR(L)+ZI(LI)*CI(L)
1700 ZINI=CI(I)-ZR(LI)*CI(L)-ZI(LI)*CR(L)
1710 CR(I)=ZINR
1720 CI(I)=ZINI
1730 NEXT L
1740 II=FNINDX(I,I,N)
1750 ZINR=FNDIVR(CR(I),CI(I),ZR(II),ZI(II))
1760 ZINI=FNDIVI(CR(I),CI(I),ZR(II),ZI(II))
1770 CR(I)=ZINR
1780 CI(I)=ZINI
1790 NEXT I
1800 NN=((N+1)*N)/2
1810 ZINR=FNDIVR(CR(N),CI(N),ZR(NN),ZI(NN))
1820 ZINI=FNDIVI(CR(N),CI(N),ZR(NN),ZI(NN))
1830 CR(N)=ZINR
1840 CI(N)=ZINI
1850 NMO=N-1
1860 FOR I=1 TO NMO
1870 K=N-I
1880 KPO=K+1
1890 KD=(K-1)*N-(K*K-K)/2
1900 FOR L=KPO TO N
1910 KL=KD+L
1920 ZINR=CR(K)-ZR(KL)*CR(L)+ZI(KL)*CI(L)
1930 ZINI=CI(K)-ZR(KL)*CI(L)-ZI(KL)*CR(L)
1940 CR(K)=ZINR
1950 CI(K)=ZINI
1960 NEXT L
1970 KK=KD+K
1980 ZINR=FNDIVR(CR(K),CI(K),ZR(KK),ZI(KK))
1990 ZINI=FNDIVI(CR(K),CI(K),ZR(KK),ZI(KK))
2000 CR(K)=ZINR
2010 CI(K)=ZINI
2020 NEXT I
2030 RETURN
2040 REM SUBROUTINE TO COMPUTE THE SINE AND COSINE INTEGRALS
2050 X2=X*X
2060 X4=X2*X2
2070 IF X>=1 THEN GOTO 2150
2080 X6=X2*X4
2090 X3=X*X2
2100 X5=X3*X2
2110 X7=X5*X2
2120 SI=X-X3/18+X5/600-X7/35280!
2130 CI=.57722+LOG(X)-X2/4+X4/96-X6/4320
2140 RETURN
2150 SX=SIN(X)
2160 CX=COS(X)
2170 FX=(X4+7.24116*X2+2.46394)/X
2180 FX=FX/(X4+9.068579*X2+7.15743)
2190 GX=(X4+7.54748*X2+1.56407)/X2
2200 GX=GX/(X4+12.72368*X2+15.72361)
2210 SI=1.57079-FX*CX-GX*SX
2220 CI=FX*SX-GX*CX
2230 RETURN
2240 REM COMPUTE ZMN TERMS
2250 A(1)=1
2260 A(5)=1
2270 A(2)=-4*CKD
2280 A(4)=A(2)
2290 A(3)=2+4*CKD*CKD
2300 ZMNR=0
2310 ZMNI=0
2320 FOR MM=-2 TO 2
2330 FOR NN=-1 TO 1 STEP 2
2340 TT=X0+MM*D
2350 BET=AM
2360 IF ABSYYAM THEN GOTO 2390
2370 BET=SQR(AM*AM+TT*TT)-NN*TT
2380 IF BET<AM/10 THEN BET=AM*AM/(2*ABS(TT))-AM^4/(8*ABS(TT)^3)
2390 X=BET*XK0
2400 ALP=XK0*NN*TT
2410 CALP=COS(ALP)
2420 SALP=SIN(ALP)
2430 GOSUB 2040
2440 ZMNR=ZMNR+A(MM+3)*(CALP*CI-SALP*SI)
2450 ZMNI=ZMNI-A(MM+3)*(SALP*CI+CALP*SI)
2460 NEXT NN
2470 NEXT MM
2480 SKDS=SKD*SKD
2490 ZMNR=ZMNR*15/SKDS
2500 ZMNI=ZMNI*15/SKDS
2510 RETURN
2520 COLOR 7,0
2530 KEY ON
2540 END
